<template>
    <div class="products-box">
        <slot name="title"></slot>
        <div class="list">
            <div class="item" v-for="(prod,i) in items" :key="prod.tradeItemId+i">
                <div class="img">
                    <img class="product" :src="prod.img">
                    <img class="btn" src="../assets/btn.png" @click="gotoDetail(prod)">
                </div>
                <div :class="singer?'info-s':'info-m'" v-if="!isTip">{{ prod.title }}</div>
                <div class="tips" v-if="isTip">
                    <ul>
                        <li v-for="(prop,i) in prod.props" :key="'prop'+i">{{ prop }}</li>
                    </ul>
                </div>
                <div class="price-like">
                    <span class="price">￥{{ prod.price }}</span>
                    <span class="like"><i class="iconfont icon-like"></i>{{ prod.cfav }}</span>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    props:{
        items:{
            type:Array,
            default(){
                return [];
            }
        },
        isTip:{
            type:Boolean,
            default:false
        },
        singer:{
            type:Boolean,
            default:false
        }
    },
    methods:{
        gotoDetail(prod){
            localStorage.setItem(prod.tradeItemId,JSON.stringify(prod));
            this.$router.push({
                name:"detail",
                params:{
                    iid:prod.tradeItemId
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .products-box{
        width: 100%;
        padding: 0px @padding-size;
        box-sizing: border-box;
    }
    .list{
        display: flex;
        flex-flow: row wrap;
        width: 100%;
        .item{
            width: 50%;
            padding: 0px  @padding-size;
            box-sizing: border-box;
            margin-bottom: 28px;
            .img{
                width: 100%;
                padding-top: 150%;
                position: relative;
                border-radius: 24px 24px 0px 0px;
                overflow: hidden;
                .product{
                    padding: 0px;
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    top: 0px;
                    left: 0px;
                    background-color: @ef;
                    object-fit: cover;
                    object-position: center;
                    box-sizing: border-box;
                    border-radius: 24px 24px 0px 0px;
                }
                .btn{
                    z-index: 10;
                    position: absolute;
                    width: 80px;
                    height: 80px;
                    bottom: 10px;
                    right: 10px;
                    background-color: rgba(0, 0, 0, 0.3);
                    border-radius: 12px;
                }
            }
            .info-m{
                margin: 10px;
                font-size: 28px;
                line-height: 38px;
                height: 76px;
                overflow: hidden;
                position: relative;
                color: @font;
                text-indent: 40px;
                &::after{
                    display: inline-block;
                    content: "...";
                    position: absolute;
                    height: 38px;
                    line-height: 38px;
                    background: linear-gradient(to right, rgba(255,255,255,0.1) 0%, rgba(255,255,255,1) 50%);
                    letter-spacing: 3px;
                    bottom: 0px;
                    right: 0px;
                    padding-left: 50px;

                }
            }
            .info-s{
                margin: 10px;
                font-size: 28px;
                overflow: hidden;
                color: @font;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            .tips{
                width: 100%;
                margin-top: 10px;
                >ul{
                    padding: 0px;
                    list-style: none;
                    height: 102px;
                    overflow: hidden;
                    >li{
                        height: 44px;
                        line-height: 44px;
                        box-sizing: border-box;
                        display: inline-block;
                        font-size: 24px;
                        padding: 0px 10px;
                        color: #6D7F89;
                        background-color: #D8E4EA;
                        margin-right: 10px;
                        margin-bottom: 10px;
                        border-radius: 6px;
                    }
                }
            }
            .price-like{
                color: @gray;
                .price{
                    font-size: 28px;
                    font-weight: bold;
                }
                .like{
                    font-size: 26px;
                    float: right;
                    .iconfont{
                        font-size:26px;
                    }
                }
            }
        }
    }
</style>
